import {MODEL_LIST,CLEAR_TOKEN,GOTO_CERT,SET_USER_TOKEN,SHOP_CHANGE_STATE,GET_SHOP_INFO,SHOW_LOADING,HIDE_LOADING,GET_TOKEN,GET_SHOP_DATA,CHANGE_REFRESH_STATE,SHOW_NOTIVEVIEW,GOTO_ADDPRODUCT} from './constants';

const initState = {
    shopState:2,//0:立即创建，1：立即完善，2:可以使用, 3:正在审核
    shopData:{
        curtainNew: 0,
        orderNew: 0,
        fansAll: 0,
        visitorToday: 0,
        transactionMonth: 0,
        viewTimesYesterday: 0,
        transactionAll: 0,
        fansYesterday: 0,
        viewTimesToday: 0,
        visitorYesterday: 0
    },
    models:[
      {
        name: '商品',
        tag: 'product',
        uri: require('../../image/product.png'),
    },  {
        name: '优惠券',
        tag: 'ticket',
        uri: require('../../image/card.png'),
    }, {
        name: '收入',
        tag: 'income',
        uri: require('../../image/tixian.png'),
    },
    ],
    shopInfo:{
        shopname: "",
        qrcode: "",
        shoplogo: "",
        shopFlag: "",
        shopid: "",
        notice: "",
        story:"",
    },
    shopImgModalVisible: false,
    isloading: true,
    token: "",
    userToken:"",
    refreshLoading: false,
    notiveViewVisible: false,
    is_from_home:false,
    is_from_account:false,
};

const reducer = (state = initState, action) => {
  switch (action.type) {
    case MODEL_LIST:
      return Object.assign({}, state, action.payload);
    case GET_SHOP_INFO:
      return Object.assign({}, state, action.payload);
    case SHOW_LOADING:
      return Object.assign({}, state, action.payload);
    case HIDE_LOADING:
      return Object.assign({}, state, action.payload);  
    case GET_TOKEN:
      return Object.assign({}, state, action.payload);  
    case GET_SHOP_DATA:
      return Object.assign({}, state, action.payload); 
    case CHANGE_REFRESH_STATE:
      return Object.assign({}, state, action.payload); 
    case SHOW_NOTIVEVIEW:
      return Object.assign({}, state, action.payload); 
    case SHOP_CHANGE_STATE:
      return Object.assign({}, state, action.payload); 
    case SET_USER_TOKEN:
      return Object.assign({}, state, action.payload);
    case CLEAR_TOKEN:
      return Object.assign({}, state, action.payload);
    case GOTO_ADDPRODUCT:
      return Object.assign({}, state, action.payload);
    case GOTO_CERT:
      return Object.assign({}, state, action.payload);
    default:
      return state;
  }
};

export default reducer;
